package com.kadron.users;

import com.kadron.dao.KUserDAO;
import com.kadron.dao.KUserImageDAO;
import com.kadron.dao.KUserKadronsDAO;
import com.kadron.datamodel.KModelCreator;
import com.kadron.entity.User;
import com.kadron.entity.UserImage;

public class KUserModelCreator implements KModelCreator {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1347643900831576325L;

	private KUserDAO userDAO;
	private KUserImageDAO userImageDAO;
	private KUserKadronsDAO userKadronsDAO;
	
	public KUserModelCreator(KUserDAO userDAO, KUserImageDAO userImageDAO,
			KUserKadronsDAO userKadronsDAO) {
		super();
		this.userDAO = userDAO;
		this.userImageDAO = userImageDAO;
		this.userKadronsDAO = userKadronsDAO;
	}

	@Override
	public KUserModel create(long id) {
		User user = (User) userDAO.find(id, User.class);
		UserImage img = userImageDAO.findByUser(user.getId());
		Long kadrons = userKadronsDAO.getUserKadrons(id);
		KUserModel model = new KUserModel(user,img, kadrons);
		return model;
	}
	
}
